<?php
include('cfg/def.php');
include('cfg/cfg.php');

include_once('lib/mysql.class.php');
include_once('lib/timer.class.php');
include_once('lib/logger.class.php');

// header('Content-Type: text/html; charset=utf-8');
header('Content-Type: text/plain; charset=utf-8');

$timer = new Timer();
$timer->start();

Logger::$log_file = $log_file_name;

$letter = get_text("letter.msg");
$answer = post2($letter);
Logger::Write(__FILE__." line: ".__LINE__, "ANSWER: ".$answer);
echo "Executing time is ".$timer->stop()." seconds";

function post2($content)
{
	$ch = curl_init();

	curl_setopt($ch, CURLOPT_URL, ROOT_URL."income.php"); 
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_POSTFIELDS, $content ); 
	curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/plain')); 
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	$result = curl_exec($ch);
	curl_close($ch);

	return $result;
}

function get_text($fname)
{
	$fdata = file_get_contents("data/".$fname);
	return $fdata;
}

